const _ = require('lodash')

const getArea = (r)=>Math.PI * r * r

const memoize = (fn)=>{
  let cache = {}
  return (args)=>{
    // cache[args] = cache[args] || fn(args)
    cache[args] = cache[args] || fn.apply(fn,[args])//为什么这里要用apply
    return cache[args]
  }
}
let getAreaWithMemory = memoize(getArea)
console.log(getAreaWithMemory(4))
